/**
 *  *2010-6-17 上午11:41:13  add 
 */
package com.base.myproject.client.HR.setting;

import java.util.ArrayList;
import java.util.List;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.BO.BaseObject;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.tools.Tools;
import com.base.myproject.client.ui.BaseGrid;
import com.base.myproject.client.ui.BaseJDBCPanel;
import com.base.myproject.client.ui.celleditor.BaseComboBoxForm;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Administrator
 *2011-09-15
 * cxghiu410@gmail.com
 */
public class HR_holidayType_Setting  extends BaseJDBCPanel
{
	BaseComboBoxForm<BaseModelData> dep;
	public HR_holidayType_Setting()
	{
		init();
	}
	public void init()
	{
		add(initWeigetx());
		registerMainStore(store);
	}
	private Widget initWeigetx()
	{
		VerticalPanel vpanel = new VerticalPanel();
		vpanel.add(createGrid());
		return vpanel;
		
	}
	
	BaseStore<BusiObject> store = null;
	BaseStore<BusiObject> getStore(){
	if(store==null) 
	{
		createStore();
	}
	return store;}

	BaseStore<BusiObject> createStore() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("HolsCode");
		type.getField("HolsCode").setType(String.class);
		type.addField("HolsName");
		type.getField("HolsName").setType(String.class);
		type.addField("pay");
		type.getField("pay").setType(Boolean.class);
		type.addField("remark");
		type.getField("remark").setType(String.class);
		StoreInfo info = new StoreInfo();
		info.setTablename("hr_Attendance_holsType");
		info.setKeyname(new String[] { "icode" });
		info.setSql("select * from hr_Attendance_holsType");
		store = new BaseStore<BusiObject>(type, info);
		return store;
	}
	

	BaseGrid<BaseObject> grid=null;
	BaseGrid<BaseObject> createGrid(){
		CheckBoxSelectionModel<BaseObject> cbs = new CheckBoxSelectionModel<BaseObject>();
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
		columns.add(cbs.getColumn());
		ColumnConfig C2 = new ColumnConfig("HolsCode", "假别代码", 80);
		TextField<String> t2 = new TextField<String>();
		C2.setEditor(new CellEditor(t2));
		columns.add(C2);
		ColumnConfig C3 = new ColumnConfig("HolsName", "假别名称", 80);
		TextField<String> t3 = new TextField<String>();
		C3.setEditor(new CellEditor(t3));
		columns.add(C3);
		CheckColumnConfig C4 = new CheckColumnConfig("pay", "是否带薪", 80);
		C4.setEditor(new CellEditor(new CheckBox()));
		columns.add(C4);

		ColumnConfig C5 = new ColumnConfig("remark", "备注", 80);
		TextField<String> t5 = new TextField<String>();
		C5.setEditor(new CellEditor(t5));
		columns.add(C5);

		ColumnModel cm = new ColumnModel(columns);
		grid = new BaseGrid(getStore(), cm, true, true);
		cbs.setSelectionMode(SelectionMode.SINGLE);
		grid.setSelectionModel(cbs);
		//holsTypegrid.setSize(851, 380);
		Tools.setResize(grid, 1.00, 0.94);
		return grid;
		}
}